package net.xxcxcxcx.xc_enhancedmob.skills.basics.individual.common;

import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.nbt.NbtCompound;
import net.xxcxcxcx.xc_enhancedmob.config.skill.SkillConfig;
import net.xxcxcxcx.xc_enhancedmob.damgesource.SkillDamageSource;
import net.xxcxcxcx.xc_enhancedmob.skills.BaseSkill;
import net.xxcxcxcx.xc_enhancedmob.skills.Ref;

public class ThornsSkill extends BaseSkill {

    public ThornsSkill(int level) {
        super(level);
    }

    public ThornsSkill(NbtCompound nbtCompound) {
        super(nbtCompound);
    }

    public ThornsSkill() {
    }

    @Override
    public SkillConfig getDefaultConfig() {
        SkillConfig skillConfig = super.getDefaultConfig();
        skillConfig.setMessage(getConfigMessage(skillConfig));
        return skillConfig;
    }

    @Override
    public String getConfigMessage(SkillConfig skillConfig) {
        if (skillConfig == null) return super.getConfigMessage(null);
        return String.format("荆棘技能，反弹（level*0.1*受到伤害）的伤害。");
    }

    @Override
    public boolean onDamaged(LivingEntity attacker, MobEntity target, DamageSource source, Ref<Float> amount, boolean ismob, boolean remote) {
        if (source instanceof SkillDamageSource source1 && source1.getPassSkill()) return true;
        if (amount.getValue() * 0.1f * getSkillLevel() < 0.1 || attacker == null) return true;
        attacker.damage(DamageSource.sting(target), amount.getValue() * 0.1f * getSkillLevel());
        return true;
    }


}
